//comment.js
const util = require('../../utils/util.js');
const urls = require('../../utils/url.js');
const win = util.getSystemHW();
Component({
  properties:{
    showStatue:{
      type: Boolean,
      value: false,
      observer: function(newVal, oldVal){

      }
    },
    param:{
      type: Object,
      value: null,
      observer: function(newVal, oldVal){}
    }
  },
  data: {
    animationData: {},
    viewHeight:win.windowHeight,
    viewWidth:win.windowWidth,
    modalFlag:false
  },
  //事件处理函数
  ready: function () {
    var animation = wx.createAnimation({
      duration: 500,
      timingFunction: 'linear',
      transformOrigin: "0% 0%",
    });
    this.animation = animation;
    this.animation.top(0).step();
    this.setData({modalFlag:this.properties.showStatue,
      animationData:this.animation.export()});
  },
  methods:{
    __closeEvent: function(e){
      var thisObj = this;
      this.animation.top(-(this.data.viewHeight)).step();
      this.setData({modalFlag: false,animationData:this.animation.export()},()=>{
        setTimeout(()=>{
          thisObj.triggerEvent("closecatalog",{isClose:true});
        },1000)
      })
    },
    __switchCatalog: function(e){
      var thisObj = this;
      var selectMuluId = e.currentTarget.dataset.catalogId;
      var selectMuluIndex = e.currentTarget.dataset.catalogIndex;
      thisObj.__closeEvent(e);
      setTimeout(()=>{
        thisObj.triggerEvent("switchcatalog",{selectMuluId:selectMuluId,selectMuluIndex:selectMuluIndex});
      },1000)
    },
    getDomSize: function(id,callback,obj){
      util.getSeletorLoction(id,obj&&obj!==undefined&&obj!==null?obj:this,(res)=>{
        if(callback){
          callback(res);
        }
      })
    },
  }
})
